package pacificlms;

import pacificlms.Verifiable.Database.Member;
import pacificlms.MainPanel.*;

/**
 * LogedMember is a sort of singleton class, the only one logged member can exist at a time, however the member can be changed and 
 * @author Brian Hume
 */
public final class LoggedMember//??Singleton??
{
    /**
     * Sets the currently logged in member and tells all listeners
     * @param NewMember The new logged in member
     */
    public static final void Set(Member NewMember)
    {
        Member = NewMember;
        MainPanel MP = MainPanel.GetMainPanel();
        if (MP != null)
        {
            MP.UpdateLogin();
        }
    }
    
    /**
     * Sets the currently logged in member to an empty member
     */
    public static final void Clear()
    {
        Member Empty = new Member();
        Empty.Name("Guest");
        Empty.Type("nonmember");
        Set(Empty);
    }
    
    /**
     * Gets the currently logged in member
     * @return currently logged in member
     */
    public static final Member getInstance() 
    {
        return Member;
    }
    private static Member Member = null;
}
